/**
 * 
 */
package infomanager;

import info.Group;

/**
 * @author vtkhanh
 * 
 */
public class GroupManager {
    private static Group[] sGroups;
    private static int sGroupNum = 0;
    private static int sCount = 0;
    
    public static Group[] getGroups() {
	if (sGroups == null) {
	    sGroups = new Group[sGroupNum];
	}
	return sGroups;
    }

    public static Group getGroupById(int id) {
	for (Group group : sGroups) {
	    if (group.getGroupId() == id) {
		return group;
	    }
	}
	return null;
    }
    
    public static void addGroup(Group group) {
	if (sCount < sGroupNum) {
	    sGroups[sCount] = group;
	    sCount++;
	}
    }
    
    public static void setGroups(Group[] groups) {
	GroupManager.sGroups = groups;
    }
    
    public static void setNumberOfGroups(int num) {
	sGroupNum = num;	
    }
    
    public static int getNumberOfGroups() {
	return sGroupNum;
    }
}
